<?php 
class DomArTestCase extends UnitTestCase {


	public function connect() {
		DomSql::init( 'localhost', 'root', '');
		$this->assertTrue( DomSql::connected() );
		try {DomSql::query('CREATE DATABASE `DomArTestDatabase`');} catch( RuntimeException $e ) {}
		$this->assertTrue( DomSql::selectDatabase( 'DomArTestDatabase' ) );
	}

	public function testConstructor() {
		
		/*try {
			DomAr::init();
			$this->assertTrue(false);
		} catch( RuntimeException $e ) {
			$this->assertTrue(true);
		}*/
		
		$this->connect();
		
		DomAr::init();
		$this->assertTrue(true);
		
	} 
	
	/**
	* @TODO Test object caching.
	*/
	public function testObjectStoring() {
		$object = new DomArTestClass_BasicFields('aa', true );
		try {
			DomAr::storeObject( $object );
			$this->assertTrue(false);
		} catch( InvalidArgumentException $e ) {
			$this->assertTrue(true);
		}
		
		$object->setId(10);
		
		DomAr::storeObject( $object );
		$this->assertTrue(true);
		
		
		$n = DomAr::getObject( $object->getId(), get_class($object) );
		$this->assertEqual( $object, $n );
		
		
		DomAr::unStoreObject( $object );
		$this->assertNotEqual( $object, DomAr::getObject( $object->getId(), get_class($object) ) );
		
		

	}

}
?>